import {
  Controller,
  Get,
  Post,
  Body,
  Put,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { ServiceService } from './service.service';
import { CreateServiceDto } from './dto/create-service.dto';
import { UpdateServiceDto } from './dto/update-service.dto';
import { ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';

@Controller('service')
@ApiTags('服务管理')
export class ServiceController {
  constructor(private readonly serviceService: ServiceService) {}

  @Post()
  create(@Body() createServiceDto: CreateServiceDto) {
    return this.serviceService.create(createServiceDto);
  }

  @Get('/skip')
  @ApiOperation({
    summary: '分页查询',
    description: '分页查管理员所在地区的服务信息',
  })
  @ApiQuery({ name: 'pageSize', description: '数据条数', required: true })
  @ApiQuery({ name: 'currentPage', description: '当前页码', required: true })
  @ApiQuery({ name: 'city', description: '城市', required: true })
  @ApiQuery({ name: 'keywords', description: '关键词', required: false })
  skipFind(
    @Query('currentPage') currentPage,
    @Query('pageSize') pageSize,
    @Query('city') city,
    @Query('keywords') keywords,
  ) {
    return this.serviceService.skipFind(
      +currentPage,
      +pageSize,
      city,
      keywords,
    );
  }

  @Get()
  findAll() {
    return this.serviceService.findAll();
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.serviceService.findOne(+id);
  }

  @Put()
  update(@Body() updateServiceDto: UpdateServiceDto) {
    return this.serviceService.update(updateServiceDto);
  }

  @Delete('/delete')
  remove(@Body() ids: number[]) {
    return this.serviceService.remove(ids);
  }
}
